<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="author" content="得闲技术 Team">
    <meta name="copyright" content="得闲技术">
    <title>编辑管理员 - Powered By 得闲技术</title>
    [#include "/admin/main/resources/list.ftl"/]
</head>
<body class="admin secondary">
<main>
    <div class="container-fluid">
        <form id="saveOrUpdateForm" class="ajax-form form-horizontal" action="update" method="post">
            <input type="hidden" name="id" value="[#if content??]${content.id}[#else]0[/#if]" />

            <div class="panel panel-default">
                <div class="panel-heading">编辑管理员</div>
                <div class="panel-body padding-5">

                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#basic" data-toggle="tab">基本信息</a>
                        </li>
                        <li>
                            <a href="#other" data-toggle="tab">其他信息</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="basic" class="tab-pane active">
                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label" for="role">角色:</label>
                                <div class="col-xs-9 col-sm-4 ">
                                    [#list roles as role]
                                        [#if content?? && content.roleIds?seq_contains(role.id)]
                                            <a data-href="../role/update?id=${role.id}"  data-toggle="iframe-modal" data-target="#iframeModal" class="btn btn-sm btn-default">${role.name}</a>
                                        [/#if]
                                    [/#list]
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label" for="username">用户名:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                    ${content.username}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label" for="mobile">手机号码:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                    ${content.mobile}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required" for="departmentId">部门:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <select name="departmentId" id="departmentId" class="selectpicker form-control"
                                            data-live-search="true" required="required">
                                        [#list departments as department]
                                            <option value="${department.id}" [#if !department.isEnabled]disabled="disabled"[/#if] [#if content.departmentId == department.id]selected="selected"[/#if]>
                                                [#if department.grade != 0]
                                                    [#list 1..department.grade as i]
                                                        &nbsp;&nbsp;
                                                    [/#list]
                                                [/#if]
                                                ${department.name}
                                            </option>
                                        [/#list]
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required" for="name">姓名:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <input id="name" name="name" value="${content.name!}" class="form-control"
                                            type="text" maxlength="20" required="required" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required" for="gender">性别:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <select name="gender" id="gender" class="selectpicker form-control" required="required">
                                        [#list gender as g]
                                            <option value="${g}" [#if content.gender==g]selected="selected"[/#if]>
                                                ${message("GenderEnum." + g)}
                                            </option>
                                        [/#list]
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label" for="avatar">头像:</label>
                                <div class="col-xs-9 col-sm-4">
                                    [#if content.avatar??]
                                        <input id="avatar" name="avatar" type="hidden" data-image-url="${imageHost}${content.avatar!}"
                                                value="${content.avatar!}" data-provide="fileinput" data-file-type="IMAGE" maxlength="500">
                                    [#else]
                                        <input id="avatar" name="avatar" type="hidden" data-image-url=""
                                                value="${content.avatar!}" data-provide="fileinput" data-file-type="IMAGE" maxlength="500">
                                    [/#if]
                                </div>
                            </div>

                        </div>

                        <div id="other" class="tab-pane">

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label" for="isEnabled">状态:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                   ${content.isEnabled?string("启用", "禁用")}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label" for="isEnabled">锁定:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                    [#if content.isAccountNonLocked]
                                        否
                                    [#else]
                                        是<span class="text-green">${content.lockedDate!}</span>
                                    [/#if]
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label">创建时间:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                    ${(content.createDate?string("yyyy-MM-dd HH:mm:ss"))!}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label" for="modifyDate">修改时间:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                    ${(content.modifyDate?string("yyyy-MM-dd HH:mm:ss"))!}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label"
                                        for="loginDate">最后登录时间:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                    ${content.loginDate!}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label"
                                        for="loginIp">最后登录IP:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                    ${content.loginIp!}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label" for="loginFailureCount">登录失败次数:</label>
                                <div class="col-xs-9 col-sm-4 form-control-static">
                                    ${content.loginFailureCount!}次
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-xs-9 col-sm-10 col-xs-offset-3 col-sm-offset-2">
                            <button class="btn btn-primary" type="submit">确 定</button>
                            <button class="btn btn-default" type="button" data-action="back">返 回</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</main>
[#include "/admin/template/iframe_modal.ftl"/]
<script>
    $().ready(function () {
        [#if !content??]
        bootbox.alert({
            title: "提示信息",
            message: "信息不存在或已删除，请检查后重试！",
            callback: function () {
                history.go(-1);
            }
        });
        [/#if]

        var $saveOrUpdateForm = $("#saveOrUpdateForm");
        // 表单验证
        $saveOrUpdateForm.validate({
            rules: {},
            messages: {},
            submitHandler: function (form) {
                $(form).ajaxSubmit();
            }
        });
    });
</script>
</body>
</html>
